package Demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-21
 * Time: 10:43
 */
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        String na;
        int wt;
        Express ex[]=new Express[n];
        for(int i=0;i<n;i++) {
            na=scan.next();
            wt=scan.nextInt();
            if(na.equals("SL"))
                ex[i]=new SLExpress(wt);
            if(na.equals("DD"))
                ex[i]=new DDExpress(wt);
        }
        for(int i=0;i<n;i++) {
            System.out.println(ex[i]);
        }
    }
}
abstract class Express{
    public int weight;

    public Express(int weight) {
        this.weight = weight;
    }

    public int getWeight() {
        return weight;
    }
    abstract int getTotal();
}
class SLExpress extends Express{

    public SLExpress(int weight) {
        super(weight);
    }

    @Override
    int getTotal() {
        int fines = weight-1;
        if (weight>0&&weight<=1){
            return 12;
        } else if (weight>1) {
            return 12+fines*2;
        }
        return 1;
    }

    @Override
    public String toString() {
        return "SLExpress："+getTotal();
    }
}
class DDExpress extends Express{

    public DDExpress(int weight) {
        super(weight);
    }

    @Override
    int getTotal() {
        int fines = weight-1;
        if (weight>0&&weight<=1){
            return 5;
        } else if (weight>1) {
            return 5+fines;
        }
        return 1;
    }

    @Override
    public String toString() {
        return "SLExpress："+getTotal();
    }
}
/* 请在这里填写答案 */